﻿Imports WeifenLuo.WinFormsUI.Docking
Public Class ImagePreviewForm
  Inherits DockContent
  Implements IChangeListener

  Private _filepath As String
  Private _wallpaper As Wallpaper

  Private Sub SetPreview(ByVal w As Wallpaper)
    _wallpaper = w

    MyBase.Show(DockPanel)
    PictureBox1.ImageLocation = Configuration.GetObject.SkinsPath & _wallpaper.Filename
    Me.Name = _wallpaper.FullName & " [Preview]"
    Me.TabText = _wallpaper.FullName & " [Preview]"
    Me.SetAutoSizeMode(Windows.Forms.AutoSizeMode.GrowAndShrink)
    Me.Height = Image.FromFile(Configuration.GetObject.SkinsPath & _wallpaper.Filename).Height + 4
    Me.SetAutoSizeMode(Windows.Forms.AutoSizeMode.GrowAndShrink)
    'AddHandler mybase., AddressOf Me.FormClosing_Eventhandler
    Refresh()
  End Sub

  Private Sub ImagePreviewForm_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.GotFocus
    MdiMain.Text = "Wallpaper Manager - " & Me.TabText
  End Sub

  Private Sub ImagePreviewForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Me.TabText = ""
  End Sub

  Private Sub ImagePreviewForm_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus
    MdiMain.Text = "Wallpaper Manager"
  End Sub

  Public Sub DoChange(ByVal o As Object) Implements IChangeListener.DoChange 
    SetPreview(o)
  End Sub

  Public Sub NotifyChange(ByVal c As Boolean) Implements IChangeListener.NotifyChange 

  End Sub
  
  Private Sub FormClosing_Eventhandler(sender As Object, e As FormClosingEventArgs) handles mybase.FormClosing 
  	e.Cancel = true 
  End Sub
  
End Class